home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / MacApp / Unsupported Samples / CRC Cards / Source / UItem.inc1.p < prev    next >
Encoding:
Text File  |  1990-07-11  |  21.1 KB  |  928 lines  |  [TEXT/MPS ]

  1. (*********************)
  2. (* methods for TItem *)
  3. (*********************)
  4. {$S ARes}
  5. PROCEDURE TItem.IItem(theCard: TCard; theName: str255);
  6.  
  7.     VAR
  8.         theTextHandler: TTextHandler;
  9.         
  10.     BEGIN
  11.         SELF.SetTheName(theName);
  12.         fCard:= theCard;
  13.         theTextHandler:= fCard.GetTextHandler;
  14.         SELF.SetTextHandler(theTextHandler);
  15.     END;   {TItem.IItem}
  16.     
  17. {$S ARes}
  18. PROCEDURE TItem.StripIllegalChars(VAR theStr: str255);
  19.  
  20.     VAR
  21.         index: 0..255;
  22.         legalChars: SET OF CHAR;
  23.         done: boolean;
  24.  
  25.     BEGIN
  26.         legalChars:= ['a'..'z', 'A'..'Z', '0'..'9', '_'];
  27.         index:= 1;
  28.         WHILE index < Length(theStr) DO
  29.             BEGIN
  30.                 done:= false;
  31.                 WHILE (NOT (theStr[index] IN legalChars)) AND (NOT done) DO
  32.                     IF Length(theStr) < index THEN
  33.                         done:= true
  34.                     ELSE
  35.                         Delete(theStr, index, 1);
  36.                 index:= index + 1;
  37.             END;
  38.     END;   {TItem.StripIllegalChars}
  39.     
  40. {$S ARes}
  41. FUNCTION TItem.GetTheName: str255;
  42.  
  43.     BEGIN
  44.         GetTheName:= fName;
  45.     END;   {TItem.GetTheName}
  46.     
  47. {$S ARes}
  48. PROCEDURE TItem.SetTheName(theName: str255);
  49.  
  50.     BEGIN
  51.         SELF.StripIllegalChars(theName);
  52.         fName:= theName;
  53.         SELF.CheckForPrefix;
  54.     END;   {TItem.SetTheName}
  55.     
  56. {$S ARes}
  57. FUNCTION TItem.GetTheItem: str255;
  58.  
  59.     BEGIN
  60.         GetTheItem:= SELF.GetTheName;
  61.     END;   {TItem.GetTheItem}
  62.     
  63. {$S ARes}
  64. FUNCTION TItem.GetTheCard: TCard;
  65.  
  66.     BEGIN
  67.         GetTheCard:= fCard;
  68.     END;    {TItem.GetTheCard}
  69.     
  70. {$S ARes}
  71. FUNCTION TItem.GetTextHandler: TTextHandler;
  72.  
  73.     BEGIN
  74.         GetTextHandler:= fTextHandler;
  75.     END;   {TItem.GetTheName}
  76.     
  77. {$S ARes}
  78. PROCEDURE TItem.SetTextHandler(theTextHandler: TTextHandler);
  79.  
  80.     BEGIN
  81.         fTextHandler:= theTextHandler;
  82.     END;   {TItem.SetTextHandler}
  83.     
  84. {$S AWriteFile}
  85. FUNCTION TItem.ReturnBytes: LONGINT;
  86.  
  87.     BEGIN
  88.         ReturnBytes:= kStringSize;
  89.     END;    {TItem.ReturnBytes}
  90.     
  91. {$S AReadFile}
  92. PROCEDURE TItem.ReadTheItem(aRefNum: INTEGER; theCard: TCard);
  93.  
  94.     VAR
  95.         theString: str255;
  96.         itemSize: LONGINT;
  97.  
  98.     BEGIN
  99.         itemSize:= kStringSize;
  100.         FailOSErr(FSRead(aRefNum, ItemSize, @theString));
  101.         SELF.IItem(theCard, theString);
  102.     END;   {TItem.ReadTheItem}
  103.     
  104. {$S AWriteFile}
  105. PROCEDURE TItem.WriteTheItem(aRefNum: INTEGER);
  106.  
  107.     VAR
  108.         itemSize: LONGINT;
  109.         theString: str255;
  110.  
  111.     BEGIN
  112.         itemSize:= kStringSize;
  113.         theString:= SELF.GetTheItem;
  114.         FailOSErr(FSWrite(aRefNum, itemSize, @theString));
  115.     END;   {TItem.WriteTheItem}
  116.     
  117. {$S ARes}
  118. PROCEDURE TItem.WriteDeclaration(theTEView: TMyTEView);
  119.  
  120.     BEGIN
  121.     END;    {TItem.WriteDeclaration}
  122.     
  123. {$S ARes}
  124. PROCEDURE TItem.CheckForPrefix;
  125.  
  126.     VAR
  127.         currentPrefix: str255;
  128.  
  129.     BEGIN
  130.         currentPrefix:= Copy(fName, 1, 1);
  131.         IF (currentPrefix <> kClassPrefix) THEN
  132.             Insert(kClassPrefix, fName, 1);
  133.     END;    {TFieldItem.CheckForPrefix}
  134.     
  135. {$S AFields}
  136. PROCEDURE TItem.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr; 
  137.         fieldType: INTEGER)); OVERRIDE;
  138. BEGIN
  139.     DoToField('TItem', NIL, bClass);
  140.     DoToField('fName', @fName, bString);
  141.     DoToField('fCard', @fCard, bString);
  142.     DoToField('fTextHandler', @fTextHandler, bObject);
  143.     INHERITED Fields(DoToField);
  144. END;
  145.  
  146.  
  147. (**************************)
  148. (* methods for TFieldItem *)
  149. (**************************)    
  150. {$S ARes}
  151. PROCEDURE TFieldItem.IFieldItem(theCard: TCard; theName, theTypeStr: str255);
  152.  
  153.     BEGIN
  154.         SELF.IItem(theCard, theName);
  155.         SELF.SetItemType(theTypeStr);
  156.         SELF.MakeGetNIL;
  157.         SELF.MakeSetNIL;
  158.         SELF.SetTheFieldsTypeConst;
  159.         SELF.SetPassByAddress;
  160.     END;    {TFieldItem.IFieldItem}
  161.  
  162. {$S ARes}
  163. FUNCTION TFieldItem.GetItemType: str255;
  164.  
  165.     BEGIN
  166.         GetItemType:= fItemType;
  167.     END;   {TItem.GetItemType}
  168.     
  169. {$S ARes}
  170. PROCEDURE TFieldItem.SetItemType(theItemType:str255);
  171.  
  172.     BEGIN
  173.         SELF.StripIllegalChars(theItemType);
  174.         fItemType:= theItemType;
  175.     END;   {TItem.SetItemType}
  176.     
  177. {$S ARes}
  178. FUNCTION TFieldItem.GetTheItem: str255; OVERRIDE;
  179.  
  180.     BEGIN
  181.         GetTheItem:= Concat(kFieldPrefix, INHERITED GetTheItem);
  182.     END;    {TFieldItem.GetTheItem}
  183.     
  184. {$S ARes}
  185. FUNCTION TFieldItem.GetTheFieldStr: str255;
  186.  
  187.     BEGIN
  188.         GetTheFieldStr:= SELF.GetTheItem;
  189.     END;    {TFieldItem.GetTheFieldStr}
  190.     
  191. {$S ARes}
  192. PROCEDURE TFieldItem.SetTheFieldsTypeConst;
  193.     BEGIN
  194.         fFieldsTypeConst:=SELF.GetTextHandler.ReturnFieldsTypeConst(SELF);
  195.     END;    {TFieldItem.SetTheFieldStr}
  196.     
  197. {$S ARes}
  198. PROCEDURE TFieldItem.SetPassByAddress;
  199.     BEGIN
  200.         fPassByAddress:=SELF.GetTextHandler.ReturnByAddress(SELF);
  201.     END;    {TFieldItem.SetPassByAddress}
  202.     
  203. {$S ARes}
  204. FUNCTION TFieldItem.GetPassByAddress: BOOLEAN;
  205.     BEGIN
  206.         GetPassByAddress:=fPassByAddress;
  207.     END;    {TFieldItem.GetPassByAddress}
  208.     
  209. {$S ARes}
  210. FUNCTION TFieldItem.GetTheFieldsTypeConst;
  211.     BEGIN
  212.         GetTheFieldsTypeConst:=fFieldsTypeConst;
  213.     END;    {TFieldItem.SetTheFieldStr}
  214.     
  215. {$S ARes}
  216. PROCEDURE TFieldItem.GetAccessors(VAR theGetter: TGetAccessorItem;
  217.                                                                     VAR theSetter: TSetAccessorItem);
  218.  
  219.     BEGIN
  220.         theGetter:= fGetAccessor;
  221.         theSetter:= fSetAccessor;
  222.     END;    {TFieldItem.GetAccessors}
  223.     
  224. {$S ARes}
  225. PROCEDURE TFieldItem.SetGetAccessor(theGetter: TGetAccessorItem);
  226.  
  227.     BEGIN
  228.         fGetAccessor:= theGetter;
  229.     END;    {TFieldItem.SetGetAccessor}
  230.     
  231. {$S ARes}
  232. PROCEDURE TFieldItem.SetSetAccessor(theSetter: TSetAccessorItem);
  233.  
  234.     BEGIN
  235.         fSetAccessor:= theSetter;
  236.     END;    {TFieldItem.SetSetAccessor}
  237.     
  238. {$S ARes}
  239. PROCEDURE TFieldItem.MakeGetNIL;
  240.  
  241.     BEGIN
  242.         fGetAccessor:= NIL;
  243.     END;    {TFieldItem.MakeGetNIL}
  244.     
  245. {$S ARes}
  246. PROCEDURE TFieldItem.MakeSetNIL;
  247.  
  248.     BEGIN
  249.         fSetAccessor:= NIL;
  250.     END;    {TFieldItem.MakeGetNIL.}
  251.     
  252. {$S ARes}
  253. FUNCTION TFieldItem.GetTheDeclaration: str255;
  254.  
  255.     VAR
  256.         theDeclarationStr: str255;
  257.  
  258.     BEGIN
  259.         GetTheDeclaration:=fTextHandler.GetFieldItemDeclaration(SELF);
  260.     END;    {TFieldItem.GetTheDeclaration}
  261.     
  262. {$S ARes}
  263. FUNCTION TFieldItem.GetTheImplDeclaration: str255;
  264.  
  265.     VAR
  266.         theDeclarationStr: str255;
  267.  
  268.     BEGIN
  269.         GetTheImplDeclaration:=fTextHandler.GetFieldItemImplDeclaration(SELF);
  270.     END;    {TFieldItem.GetTheImplDeclaration}
  271.     
  272. {$S ARes}
  273. PROCEDURE TFieldItem.WriteDeclaration(theTEView: TMyTEView); OVERRIDE;
  274.  
  275.     VAR
  276.         theDeclarationStr: str255;
  277.  
  278.     BEGIN
  279.         theDeclarationStr:=SELF.GetTheDeclaration;
  280.         fTextHandler.Replace(theDeclarationStr, '^VOID', 'void');
  281.         theTEView.WriteToMyTEView(theDeclarationStr);
  282.         theTEView.WriteEndOfLine;
  283.     END;    {TFieldItem.WriteDeclaration}
  284.     
  285. {$S ARes}
  286. PROCEDURE TFieldItem.CheckForPrefix; OVERRIDE;
  287.  
  288.     VAR
  289.         currentPrefix: str255;
  290.  
  291.     BEGIN
  292.         currentPrefix:= Copy(fName, 1, 1);
  293.         IF (currentPrefix = kFieldPrefix) THEN
  294.             Delete(fName, 1, 1);
  295.     END;    {TFieldItem.CheckForPrefix}
  296.         
  297. {$S ARes}
  298. FUNCTION TMethodItem.GetNumRealMethods: integer;
  299.  
  300.     BEGIN
  301.         GetNumRealMethods:= 1;    {count me, I'm real.}
  302.     END;    {TMethodItem.GetNumRealMethods}
  303.     
  304. {$S AWriteFile}
  305. FUNCTION TFieldItem.ReturnBytes: LONGINT; OVERRIDE;
  306.  
  307.     BEGIN
  308.         ReturnBytes:= 2 * kStringSize;
  309.     END;    {TFieldItem.ReturnBytes}
  310.  
  311. {$S AReadFile}
  312. PROCEDURE TFieldItem.ReadTheItem(aRefNum: INTEGER; theCard: TCard); OVERRIDE;
  313.  
  314.     VAR
  315.         theName,
  316.         theType: str255;
  317.         itemSize: LONGINT;
  318.  
  319.     BEGIN
  320.         itemSize:= kStringSize;
  321.         FailOSErr(FSRead(aRefNum, ItemSize, @theName));
  322.         FailOSErr(FSRead(aRefNum, ItemSize, @theType));
  323.         SELF.IFieldItem(theCard, theName, theType);
  324.     END;    {TFieldItem.ReadTheItem}
  325.  
  326. {$S AWriteFile}
  327. PROCEDURE TFieldItem.WriteTheItem(aRefNum: INTEGER); OVERRIDE;
  328.  
  329.     VAR
  330.         itemSize: LONGINT;
  331.         theString: str255;
  332.  
  333.     BEGIN
  334.         itemSize:= kStringSize;
  335.         theString:= SELF.GetTheName;
  336.         FailOSErr(FSWrite(aRefNum, itemSize, @theString));
  337.         FailOSErr(FSWrite(aRefNum, itemSize, @fItemType));
  338.     END;    {TFieldItem.WriteTheItem}
  339.     
  340. {$S AFields}
  341. PROCEDURE TFieldItem.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr; 
  342.         fieldType: INTEGER)); OVERRIDE;
  343.  
  344.     BEGIN
  345.         DoToField('TFieldItem', NIL, bClass);
  346.         DoToField('fItemType', @fItemType, bString);
  347.         DoToField('fGetAccessor', @fGetAccessor, bObject);
  348.         DoToField('fSetAccessor', @fSetAccessor, bObject);
  349.         DoToField('fFieldsTypeConst', @fFieldsTypeConst, bString);
  350.         DoToField('fPassByAddress', @fPassByAddress, bBoolean);
  351.         INHERITED Fields(DoToField);
  352.     END;   {TFieldItem.Fields}
  353.  
  354.  
  355. (***************************)
  356. (* methods for TMethodItem *)
  357. (***************************)
  358. {$S ARes}
  359. FUNCTION TMethodItem.GetOVERRIDE: boolean;
  360.  
  361.     BEGIN
  362.         GetOVERRIDE:= fOVERRIDE;
  363.     END;    {TMethodItem.GetOVERRIDE}
  364.     
  365. {$S ARes}
  366. PROCEDURE TMethodItem.SetOVERRIDE(overrideIt: boolean);
  367.  
  368.     BEGIN
  369.         fOVERRIDE:= overrideIt;
  370.     END;    {TMethodItem.GetOVERRIDE}
  371.     
  372. {$S ARes}
  373. PROCEDURE TMethodItem.IMethodItem(theCard: TCard; theName: str255; makeItOVERRIDE: boolean);
  374.  
  375.     BEGIN
  376.         SELF.SetOVERRIDE(makeItOVERRIDE);
  377.         SELF.IItem(theCard, theName);
  378.     END;    {TMethodItem.IMethodItem}
  379.     
  380. {$S AWriteFile}
  381. FUNCTION TMethodItem.ReturnBytes: LONGINT; OVERRIDE;
  382.  
  383.     BEGIN
  384.         ReturnBytes:= kStringSize + SIZEOF(boolean);
  385.     END;    {TMethodItem.ReturnBytes}
  386.  
  387. {$S AReadFile}
  388. PROCEDURE TMethodItem.ReadTheItem(aRefNum: INTEGER; theCard: TCard); OVERRIDE;
  389.  
  390.     VAR
  391.         theString: str255;
  392.         isOVERRIDE: boolean;
  393.         itemSize: LONGINT;
  394.  
  395.     BEGIN
  396.         itemSize:= kStringSize;
  397.         FailOSErr(FSRead(aRefNum, ItemSize, @theString));
  398.         itemSize:=  SIZEOF(boolean);
  399.         FailOSErr(FSRead(aRefNum, ItemSize, @isOVERRIDE));
  400.         SELF.IMethodItem(theCard, theString, isOVERRIDE);
  401.     END;   {TMethodItem.ReadTheItem}
  402.     
  403. {$S AWriteFile}
  404. PROCEDURE TMethodItem.WriteTheItem(aRefNum: INTEGER); OVERRIDE;
  405.  
  406.     VAR
  407.         itemSize: LONGINT;
  408.         theString: str255;
  409.         isOVERRIDE: boolean;
  410.  
  411.     BEGIN
  412.         itemSize:= kStringSize;
  413.         theString:= SELF.GetTheItem;
  414.         FailOSErr(FSWrite(aRefNum, itemSize, @theString));
  415.         itemSize:= SIZEOF(boolean);
  416.         isOVERRIDE:= SELF.GetOVERRIDE;
  417.         FailOSErr(FSWrite(aRefNum, itemSize, @isOVERRIDE));
  418.     END;   {TMethodItem.WriteTheItem}
  419.  
  420. {$S ARes}
  421. FUNCTION TMethodItem.GetTheCodeLine: str255;
  422. BEGIN
  423.     GetTheCodeLine:='Big ERROR';
  424. END;
  425.     
  426. {$S ARes}
  427. PROCEDURE TMethodItem.WriteDeclaration(theTEView: TMyTEView); OVERRIDE;
  428.  
  429.     VAR
  430.         theDeclarationStr: str255;
  431.  
  432.     BEGIN
  433.         theDeclarationStr:=SELF.GetTheDeclaration;
  434.         theTEView.WriteToMyTEView(theDeclarationStr);
  435.     END;    {TMethodItem.WriteDeclaration}
  436.  
  437. {$S ARes}
  438. PROCEDURE TMethodItem.CheckForPrefix; OVERRIDE;
  439.  
  440.     BEGIN
  441.         {DO NOTHING: let the names of the methods be whatever the user wants}
  442.     END;    {TMethodItem.CheckForPrefix}
  443.     
  444. {$S ARes}
  445. FUNCTION TMethodItem.GetTheDeclaration: str255;
  446.  
  447.     VAR
  448.         theClass: TItem;
  449.         theClassName: str255;
  450.  
  451.     BEGIN
  452.         theClass:= fCard.GetTheClass;
  453.         theClassName:= theClass.GetTheItem;
  454.         IF fOVERRIDE THEN
  455.             GetTheDeclaration:= fTextHandler.GetOverrideMethStr(SELF)
  456.         ELSE
  457.             GetTheDeclaration:= fTextHandler.GetStdMethStr(SELF);
  458.     END;    {TMethodItem.GetTheDeclaration}
  459.     
  460. {$S ARes}
  461. FUNCTION TMethodItem.GetTheImplDeclaration: str255;
  462.  
  463.     VAR
  464.         theClass: TItem;
  465.         theClassName: str255;
  466.  
  467.     BEGIN
  468.         theClass:= fCard.GetTheClass;
  469.         theClassName:= theClass.GetTheItem;
  470.         IF fOVERRIDE THEN
  471.             GetTheImplDeclaration:= fTextHandler.GetOverrideImplMethStr(SELF)
  472.         ELSE
  473.             GetTheImplDeclaration:= fTextHandler.GetStdImplMethStr(SELF);
  474.     END;    {TMethodItem.GetTheImplDeclaration}
  475.  
  476. {$S ARes}
  477. PROCEDURE TMethodItem.WriteInlineProcedures(theTEView: TMyTEView);
  478. BEGIN                {NOTE:Normal methods have no Inline definitions}
  479. END;
  480.  
  481. {$S ARes}
  482. PROCEDURE TMethodItem.WriteImplementation(theTEView: TMyTEView);
  483.  
  484.     BEGIN
  485.         theTEView.WriteToMyTEView(fTextHandler.GetStdMethodImplementationStr(SELF));
  486.     END;    {TMethodItem.WriteImplementation}
  487.  
  488. {$S ARes}
  489. PROCEDURE TMethodItem.StripIllegalChars(VAR theStr: str255); OVERRIDE;
  490.  
  491.     VAR
  492.         numbers: SET OF CHAR;
  493.  
  494.     BEGIN
  495.         INHERITED StripIllegalChars(theStr);
  496.         numbers:= ['0'..'9'];
  497.         WHILE theStr[1] IN numbers DO
  498.             Delete(theStr,1,1);
  499.     END;   {TMethodItem.StripIllegalChars}    
  500.     
  501. {$S AFields}
  502. PROCEDURE TMethodItem.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr; 
  503.         fieldType: INTEGER)); OVERRIDE;
  504.  
  505.     BEGIN
  506.         DoToField('TMethodItem', NIL, bClass);
  507.         DoToField('fOVERRIDE', @fOVERRIDE, bBoolean);
  508.         INHERITED Fields(DoToField);
  509.     END;   {TMethodItem.Fields}
  510.  
  511. (*********************************)
  512. (* methods for TFieldsMethodItem *)
  513. (*********************************)
  514.     
  515. {$S ARes}
  516. FUNCTION TFieldsMethodItem.GetTheDeclaration: str255; OVERRIDE;
  517.  
  518.     BEGIN
  519.         GetTheDeclaration:= fTextHandler.GetFieldsMethodDecStr(SELF);
  520.     END;    {TFieldsMethodItem.GetTheDeclaration}
  521.     
  522. {$S ARes}
  523. FUNCTION TFieldsMethodItem.GetTheImplDeclaration: str255; OVERRIDE;
  524.  
  525.     BEGIN
  526.         GetTheImplDeclaration:= fTextHandler.GetImplFieldsMethodDecStr(SELF);
  527.     END;    {TFieldsMethodItem.GetTheImplDeclaration}
  528.     
  529. {$S ARes}
  530. PROCEDURE TFieldsMethodItem.WriteImplementation(theTEView: TMyTEView); OVERRIDE;
  531.  
  532.     VAR
  533.         aList: TMyList;
  534.         
  535.     PROCEDURE WriteTheLine(theFieldItem: TFieldItem);
  536.     
  537.         VAR
  538.             theCodeLine: str255;
  539.     
  540.         BEGIN
  541.             theTEView.WriteToMyTEView(fTextHandler.GetFieldsMethodCodeLineStr(TheFieldItem));
  542.         END;    {WriteTheLine}
  543.  
  544.     BEGIN
  545.         theTEView.WriteToMyTEView(fTextHandler.GetFieldsMethodImpStr1);
  546.         theTEView.WriteToMyTEView(SELF.GetTheImplDeclaration);
  547.         theTEView.WriteToMyTEView(fTextHandler.GetFieldsMethodImpStr2(SELF));
  548.         
  549.         aList:= fCard.GetFields;
  550.         aList.Each(WriteTheLine);
  551.         aList:= fCard.GetCollaborators;
  552.         aList.Each(WriteTheLine);
  553.         
  554.         theTEView.WriteToMyTEView(fTextHandler.GetFieldsMethodImpStr3);
  555.     END;    {TFieldsMethodItem.WriteImplementation}
  556.     
  557. {$S ARes}
  558. FUNCTION TFieldsMethodItem.GetNumRealMethods: integer; OVERRIDE;
  559.  
  560.     BEGIN
  561.         GetNumRealMethods:= 0;    {don't count me, I'm not real.}
  562.     END;    {TFieldsMethodItem.GetNumRealMethods}
  563.     
  564. {$S ARes}
  565. FUNCTION TFieldsMethodItem.ReturnBytes: LONGINT; OVERRIDE;
  566.  
  567.     BEGIN
  568.         ReturnBytes:= 0;
  569.     END;    {TFieldsMethodItem.ReturnBytes}
  570.     
  571. {$S ARes}
  572. PROCEDURE TFieldsMethodItem.ReadTheItem(aRefNum: INTEGER; theCard: TCard); OVERRIDE;
  573.  
  574.     BEGIN
  575.         {do nothing}
  576.     END;    {TFieldsMethodItem.ReadTheItem}
  577.     
  578. {$S ARes}
  579. PROCEDURE TFieldsMethodItem.WriteTheItem(aRefNum: INTEGER); OVERRIDE;
  580.  
  581.     BEGIN
  582.         {do nothing}
  583.     END;    {TFieldsMethodItem.WriteTheItem}
  584.  
  585. (*****************************)
  586. (* methods for TAccessorItem *)
  587. (*****************************)
  588. {$S ARes}
  589. PROCEDURE TAccessorItem.IAccessorItem(theCard: TCard; theName: str255; 
  590.                                                                                     ourField: TFieldItem);
  591.                                         
  592.     BEGIN
  593.         SELF.IMethodItem(theCard, theName, NOT kOVERRIDE);
  594.         SELF.SetFieldReference(ourField);
  595.     END;    {TAccessorItem.IAccessorItem}
  596.     
  597. {$S ARes}
  598. PROCEDURE TAccessorItem.SetFieldReference(theField: TFieldItem);
  599.     
  600.     BEGIN
  601.         fFieldAccessed:= theField;
  602.     END;    {TAccessorItem.SetFieldReference}
  603.     
  604. {$S ARes}
  605. FUNCTION TAccessorItem.GetFieldAccessed: TFieldItem;
  606.  
  607.     BEGIN
  608.         GetFieldAccessed:=fFieldAccessed;
  609.     END; {TAccessorItem.GetFieldAccessed}
  610.     
  611. {$S ARes}
  612. PROCEDURE TAccessorItem.SetFunction(makeItAFunction: boolean);
  613.     
  614.     BEGIN
  615.         fFunction:= makeItAFunction;
  616.     END;    {TAccessorItem.}
  617.     
  618. {$S ARes}
  619. FUNCTION TAccessorItem.GetTheItem: str255; OVERRIDE;
  620.     
  621.     BEGIN
  622.         GetTheItem:= 'ERROR IN TACCESSORITEM.GETTHEITEM';
  623.     END;    {TAccessorItem.}
  624.     
  625. {$S ARes}
  626. FUNCTION TAccessorItem.GetTheDeclaration: str255; OVERRIDE;
  627.     
  628.     VAR
  629.         theClass: TItem;
  630.         aString: str255;
  631.     
  632.     BEGIN
  633.         ProgramBreak('ERROR in TACCESSORITEM.GETTHEDECLARATION');
  634.     END;    {TAccessorItem.}
  635.     
  636. {$S ARes}
  637. FUNCTION TAccessorItem.GetTheImplDeclaration: str255; OVERRIDE;
  638.     
  639.     VAR
  640.         theClass: TItem;
  641.         aString: str255;
  642.     
  643.     BEGIN
  644.         ProgramBreak('ERROR in TACCESSORITEM.GETTHEimplDECLARATION');
  645.     END;    {TAccessorItem.GetTheImplDeclaration}
  646.     
  647. {$S ARes}
  648. FUNCTION TAccessorItem.GetParameter: str255;
  649.  
  650.     BEGIN
  651.         GetParameter:= Concat('the', SELF.GetTheName);
  652.     END;    {TAccessorItem.GetParameter}
  653.  
  654. {$S ARes}
  655. PROCEDURE TAccessorItem.WriteImplementation(theTEView: TMyTEView); OVERRIDE;
  656.  
  657.     BEGIN
  658.         theTEView.WriteToMyTEView(SELF.GetTheCodeLine);
  659.     END;    {TAccessorItem.WriteImplementation}
  660.         
  661. {$S ARes}
  662. FUNCTION TAccessorItem.GetNumRealMethods: integer; OVERRIDE;
  663.  
  664.     BEGIN
  665.         GetNumRealMethods:= 0;    {don't count me, I'm not real.}
  666.     END;    {TAccessorItem.GetNumRealMethods}
  667.     
  668. {$S AWriteFile}
  669. FUNCTION TAccessorItem.ReturnBytes: LONGINT; OVERRIDE;
  670.  
  671.     BEGIN
  672.         ReturnBytes:= 0;
  673.     END;    {TItem.ReturnBytes}
  674.  
  675. {$S AReadFile}
  676. PROCEDURE TAccessorItem.ReadTheItem(aRefNum: INTEGER; theCard: TCard); OVERRIDE;
  677.  
  678.     BEGIN
  679.         {do nothing}
  680.     END;    {TItem.ReadTheItem}
  681.     
  682. {$S AWriteFile}
  683. PROCEDURE TAccessorItem.WriteTheItem(aRefNum: INTEGER); OVERRIDE;
  684.  
  685.     BEGIN
  686.         {do nothing}
  687.     END;    {TItem.WriteTheItem}
  688.     
  689. {$S AFields}
  690. PROCEDURE TAccessorItem.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr; 
  691.         fieldType: INTEGER)); OVERRIDE;
  692.  
  693.     BEGIN
  694.         DoToField('TAccessorItem', NIL, bClass);
  695.         DoToField('fFunction', @fFunction, bBoolean);
  696.         DoToField('fFieldAccessed', @fFieldAccessed, bObject);
  697.         INHERITED Fields(DoToField);
  698.     END;   {TMethodItem.Fields}
  699.  
  700.  
  701. (********************************)
  702. (* methods for TGetAccessorItem *)
  703. (********************************)
  704. {$S ARes}
  705. FUNCTION TGetAccessorItem.GetTheCodeLine: str255; OVERRIDE;
  706. BEGIN
  707.         GetTheCodeLine:=fTextHandler.GetGetAccessorImplementation(SELF);
  708. END; {TGetAccessorItem.GetTheCodeLine}
  709.  
  710. {$S ARes}
  711. FUNCTION TGetAccessorItem.GetTheItem: str255; OVERRIDE;
  712.     
  713.     BEGIN
  714.         GetTheItem:= Concat(kGetAccessorPrefix, SELF.GetTheName);
  715.     END;    {TGetAccessorItem.GetTheItem}
  716.  
  717. {$S ARes}
  718. FUNCTION TGetAccessorItem.GetTheDeclaration: str255; OVERRIDE;
  719.     
  720.     BEGIN
  721.         GetTheDeclaration:= fTextHandler.GetGetAccessorStr(SELF)
  722.     END;    {TGetAccessorItem.GetTheDeclaration}
  723.     
  724. {$S ARes}
  725. FUNCTION TGetAccessorItem.GetTheImplDeclaration: str255; OVERRIDE;
  726.     
  727.     BEGIN
  728.         GetTheImplDeclaration:= fTextHandler.GetImplGetAccessorStr(SELF);
  729.     END;    {TGetAccessorItem.GetTheImplDeclaration}
  730.     
  731. {$S ARes}
  732. PROCEDURE TGetAccessorItem.WriteInlineProcedures(theTEView: TMyTEView); OVERRIDE;
  733.  
  734. BEGIN    
  735.     theTEView.WriteToMyTEView(fTextHandler.GetInlineGetAccessorStr(SELF));
  736. END;
  737.  
  738. PROCEDURE TGetAccessorItem.CheckForPrefix; OVERRIDE;
  739.  
  740.     VAR
  741.         currentPrefix: Str255;
  742.         prefixLength : Integer;
  743.  
  744.     BEGIN
  745.         prefixLength:=length(kGetAccessorPrefix);
  746.         if length(fName) > prefixLength THEN
  747.           BEGIN
  748.                 currentPrefix:= Copy(fName, 1, prefixLength);
  749.                 IF (currentPrefix = kGetAccessorPrefix) THEN
  750.                     Delete(fName, 1, prefixLength);
  751.             END;
  752.     END;    {TGetAccessorItem.CheckForPrefix}
  753.     
  754. {$S AClose}
  755. PROCEDURE TGetAccessorItem.Free; OVERRIDE;
  756.     
  757.     BEGIN
  758.         fFieldAccessed.MakeGetNIL;
  759.         INHERITED Free;
  760.     END;    {TGetAccessorItem.Free}
  761.  
  762.  
  763. (***********************************)
  764. (* methods for TSetAccessorItem *)
  765. (***********************************)
  766. {$S ARes}
  767. FUNCTION TSetAccessorItem.GetTheCodeLine: str255; OVERRIDE;
  768. BEGIN
  769.     GetTheCodeLine:=fTextHandler.GetSetAccessorImplementation(SELF);
  770. END; {TSetAccessorItem.GetTheCodeLine}
  771.     
  772. {$S ARes}
  773. FUNCTION TSetAccessorItem.GetTheItem: str255; OVERRIDE;
  774.     
  775.     BEGIN
  776.         GetTheItem:= Concat(kSetAccessorPrefix, SELF.GetTheName);
  777.     END;    {TSetAccessorItem.GetTheItem}
  778.  
  779. {$S ARes}
  780. FUNCTION TSetAccessorItem.GetTheDeclaration: str255; OVERRIDE;
  781.     
  782.     BEGIN
  783.         GetTheDeclaration:= fTextHandler.GetSetAccessorStr(SELF);
  784.     END;    {TSetAccessorItem.GetTheDeclaration}
  785.     
  786. {$S ARes}
  787. FUNCTION TSetAccessorItem.GetTheImplDeclaration: str255; OVERRIDE;
  788.     
  789.     BEGIN
  790.         GetTheImplDeclaration:= fTextHandler.GetImplSetAccessorStr(SELF);
  791.     END;    {TSetAccessorItem.GetTheImplDeclaration}
  792.     
  793. {$S ARes}
  794. PROCEDURE TSetAccessorItem.WriteInlineProcedures(theTEView: TMyTEView); OVERRIDE;
  795.  
  796.     BEGIN                
  797.         theTEView.WriteToMyTEView(fTextHandler.GetInlineSetAccessorStr(SELF));
  798.     END;
  799.  
  800. {$S ARes}
  801. PROCEDURE TSetAccessorItem.CheckForPrefix; OVERRIDE;
  802.  
  803.     VAR
  804.         currentPrefix,
  805.         nextLetter: str255;
  806.         prefixLength : Integer;
  807.  
  808.     BEGIN
  809.         prefixLength:=length(kSetAccessorPrefix);
  810.         if length(fName) > prefixLength THEN
  811.           BEGIN
  812.                 currentPrefix:= Copy(fName, 1, prefixLength);
  813.                 IF (currentPrefix = kSetAccessorPrefix) THEN
  814.                     Delete(fName, 1, prefixLength);
  815.             END;
  816.     END;    {TSetAccessorItem.CheckForPrefix}
  817.     
  818. {$S AClose}
  819. PROCEDURE TSetAccessorItem.Free; OVERRIDE;
  820.     
  821.     BEGIN
  822.         fFieldAccessed.MakeSetNIL;
  823.         INHERITED Free;
  824.     END;    {TSetAccessorItem.Free}
  825.  
  826.  
  827. (***********************************)
  828. (* methods for TCollaboratorItem *)
  829. (***********************************)
  830. {$S ARes}
  831. PROCEDURE TCollaboratorItem.ICollaboratorItem(theCard: TCard; theName: str255);
  832.  
  833.     VAR
  834.         ourTypeStr: str255;
  835.         
  836.     BEGIN
  837.         SELF.IFieldItem(theCard, theName, kEmptyString);
  838.         ourTypeStr:= SELF.GetTheItem;
  839.         SELF.SetItemType(ourTypeStr);
  840.     END;    {TCollaboratorItem.ICollaboratorItem}
  841.     
  842. {$S ARes}
  843. PROCEDURE TCollaboratorItem.CheckForPrefix; OVERRIDE;
  844.  
  845.     VAR
  846.         currentPrefix,
  847.         nextLetter: str255;
  848.  
  849.     BEGIN
  850.         currentPrefix:= Copy(fName, 1, 1);
  851.         IF (currentPrefix = kClassPrefix) THEN
  852.             BEGIN
  853.                 nextLetter:= Copy(fName, 2, 1);
  854.                 IF (nextLetter >= 'A') AND (nextLetter <= 'Z') THEN
  855.                     Delete(fName, 1, 1);
  856.             END;
  857.     END;    {TCollaboratorItem.CheckForPrefix}
  858.     
  859. {$S ARes}
  860. FUNCTION TCollaboratorItem.GetTheItem: str255; OVERRIDE;
  861.  
  862.     BEGIN
  863.         GetTheItem:= Concat(kClassPrefix, SELF.fName);
  864.     END;    {TCollaboratorItem.GetTheItem}
  865.     
  866. {$S ARes}
  867. FUNCTION TCollaboratorItem.GetTheFieldStr: str255;
  868.  
  869.     BEGIN
  870.         GetTheFieldStr:= Concat(kFieldPrefix, SELF.fName);
  871.     END;    {TCollaboratorItem.GetTheFieldStr}
  872.     
  873. {$S ARes}
  874. PROCEDURE TCollaboratorItem.SetTheFieldsTypeConst; OVERRIDE;
  875.  
  876.     BEGIN
  877.         fFieldsTypeConst:= 'bObject';
  878.     END;    {TCollaboratorItem.SetTheFieldsTypeConst}
  879.     
  880. {$S ARes}
  881. FUNCTION TCollaboratorItem.GetTheDeclaration: str255; OVERRIDE;
  882.  
  883.     BEGIN
  884.         GetTheDeclaration:= fTextHandler.GetCollaboratorDeclaration(SELF);
  885.     END;    {TCollaboratorItem.GetTheDeclaration}
  886.     
  887. {$S ARes}
  888. FUNCTION TCollaboratorItem.GetTheImplDeclaration: str255; OVERRIDE;
  889.  
  890.     BEGIN
  891.         GetTheImplDeclaration:= fTextHandler.GetImplCollaboratorDeclaration(SELF);
  892.     END;    {TCollaboratorItem.GetTheImplDeclaration}
  893.     
  894. {$S AWriteFile}
  895. FUNCTION TCollaboratorItem.ReturnBytes: LONGINT; OVERRIDE;
  896.  
  897.     BEGIN
  898.         ReturnBytes:= kStringSize;
  899.     END;    {TCollaboratorItem.ReturnBytes}
  900.  
  901. {$S AReadFile}
  902. PROCEDURE TCollaboratorItem.ReadTheItem(aRefNum: INTEGER; theCard: TCard); OVERRIDE;
  903.  
  904.     VAR
  905.         theName: str255;
  906.         itemSize: LONGINT;
  907.  
  908.     BEGIN
  909.         itemSize:= kStringSize;
  910.         FailOSErr(FSRead(aRefNum, ItemSize, @theName));
  911.         SELF.ICollaboratorItem(theCard, theName);
  912.     END;    {TCollaboratorItem.ReadTheItem}
  913.  
  914. {$S AWriteFile}
  915. PROCEDURE TCollaboratorItem.WriteTheItem(aRefNum: INTEGER); OVERRIDE;
  916.  
  917.     VAR
  918.         itemSize: LONGINT;
  919.         theString: str255;
  920.  
  921.     BEGIN
  922.         itemSize:= kStringSize;
  923.         theString:= SELF.GetTheName;
  924.         FailOSErr(FSWrite(aRefNum, itemSize, @theString));
  925.     END;   {TCollaboratorItem.WriteTheItem}
  926.     
  927.  
  928.